<template>
  <el-form ref="form" :model="form" label-width="120px">
    <div class="xuanfu">
      <el-button
        type="primary"
        style="margin-bottom: 5px"
        @click="AddInterToPhys"
        >Add InterToPhys</el-button
      >

      <!--   <el-input v-model="item.content"></el-input> -->
      <el-row :gutter="20">
        <el-col :span="6"
          ><div
            class="grid-content bg-purple"
            style="text-align: center; vertical-align: middle; padding: 10px"
          >
            Short Label
          </div></el-col
        >
        <el-col :span="6"
          ><div
            class="grid-content bg-purple"
            style="text-align: center; vertical-align: middle; padding: 10px"
          >
            Symbol
          </div></el-col
        >
        <el-col :span="6"
          ><div
            class="grid-content bg-purple"
            style="text-align: center; vertical-align: middle; padding: 10px"
          >
            MASK
          </div></el-col
        >
        <el-col :span="6"
          ><div
            class="grid-content bg-purple"
            style="text-align: center; vertical-align: middle; padding: 10px"
          >
            BITFIELD
          </div></el-col
        >
      </el-row>
      <!-- <interTophysVue></interTophysVue> -->
      <li
        style="list-style-type: none"
        v-for="(item, index) in textArr"
        :key="index"
      >
        <el-row :gutter="20">
          <el-col :span="6"
            ><div class="grid-content bg-purple">
              <el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
        </el-row>
      </li>

      <!--   <el-input v-model="item.content"></el-input> -->

      <!-- <interTophysVue></interTophysVue> -->
    </div>
    <div class="xuanfu">
      <el-button
        type="success"
        style="margin-bottom: 5px"
        @click="AddPhysToInter"
        >Add PhysToInter</el-button
      >

      <li
        style="list-style-type: none"
        v-for="(item, index) in textArrPI"
        :key="index"
      >
        <!--   <el-input v-model="item.content"></el-input> -->
        <el-row :gutter="20">
          <el-col :span="6"
            ><div class="grid-content bg-purple">
              <el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
          <el-col :span="6"
            ><div class="grid-content bg-purple"><el-input></el-input></div
          ></el-col>
        </el-row>
      </li>
    </div>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from 'vue'
import { useStore } from '@/render/store/index'

export default defineComponent({
  components: {
    // interTophysVue,
    // physToIntVue
  },
  setup() {
    let store = useStore()
    let info = ref()
    let editableTabs = computed(() => {
      return store.state.base.tabs
    })

    let isEmpty = computed(() => {
      if (editableTabs.value.length > 0) {
        return false
      } else {
        return true
      }
    })
    let numP = 1
    let numI = 1
    let editableTabsValue = computed(() => {
      return store.state.base.activeTabName
    })
    let textArr = ref([
      { shortTAble: '', Symbol: '', Mask: '', bitfieldLimits: '' }
    ])

    let textArrPI = ref([
      { shortTAble: '', Symbol: '', Mask: '', bitfieldLimits: '' }
    ])
    const removeTab = (targetName: string) => {
      const deleteTabIndex = editableTabs.value?.findIndex(
        (item) => item.title === targetName
      )
      store.dispatch('base/closePage', deleteTabIndex)
    }
    const AddInterToPhys = () => {
      textArr.value.push({
        shortTAble: '   ',
        Symbol: '  ',
        Mask: '  ',
        bitfieldLimits: '  '
      })
    }
    const AddPhysToInter = () => {
      textArrPI.value.push({
        shortTAble: '   ',
        Symbol: '  ',
        Mask: '  ',
        bitfieldLimits: '  '
      })
    }
    return {
      isEmpty,
      editableTabs,
      editableTabsValue,
      textArr,
      textArrPI,
      info,
      removeTab,
      AddInterToPhys,
      AddPhysToInter
    }
  },
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    }
  },
  watch: {
    orderData: function (newData, oldData) {
      console.log(newData) //newData就是orderData
      // this.itemArrPI = newData;
      //	methods的函数在这里调用可以获取到newOrderData的值
    }
  }
})
</script>

<style scoped lang="less">
@import '../../../assets/style/index';
@import '../../../assets/style/compu.css';
.editor {
  height: 100%;
  width: 100%;
  .isEmpty {
    display: none;
  }
  & > :deep(.el-tabs__header) {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    height: @main-row-height;
    border-bottom: @border-style;
    background-color: @main-background-color;
    margin: 0;
    .el-tabs__nav-wrap.is-scrollable {
      padding: 0 30px;
    }
    .el-tabs__nav-wrap {
      .el-tabs__nav-next,
      .el-tabs__nav-prev {
        width: 30px;
        height: @main-row-height;
        line-height: @main-row-height;
        .el-icon {
          box-sizing: content-box;
          margin: 5px;
          padding: 4px;
        }
        .el-icon:hover {
          background-color: #ccc;
        }
      }
      .el-tabs__nav-scroll {
        .el-tabs__nav {
          border-radius: 0;
          border: 0;
          .el-tabs__item {
            height: @main-row-height;
            line-height: @main-row-height;
          }
          .el-tabs__item:hover {
            background-color: #ccc;
          }
          .el-tabs__item.is-active {
            background-color: @content-background-color;
            border-bottom: 3px #409eff solid;
          }
        }
      }
    }
  }
  & > :deep(.el-tabs__content) {
    max-height: calc(~'100% - @{main-row-height}');
    min-height: calc(~'100% - @{main-row-height}');
    overflow-y: auto;
    background-color: @content-background-color;
  }
}
.empty {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
